﻿using System;
using System.ComponentModel;
using IntegratedMeasuring.Utils;
using Newtonsoft.Json;
using SqlSugar;

namespace IntegratedMeasuring.ViewModels.Scheme;

public class ProductionOrder : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler? PropertyChanged;
    
    [SugarColumn(IsPrimaryKey = true)]
    public long Id { get; set; }
    // 工单名称
    public string Name { get; set; }  
    // 周期号
    public string BatchNumber { get; set; }
    // 工单描述
    [SugarColumn(IsIgnore = true)]
    public string Remarks { get; set; }
    
    // 测试文件名称
    public string TestConditions { get; set; }
    
    // 工单数量
    public int PlanNumber { get; set; } = 0;
    
    // Pass数量
    public int PassNumber { get; set; } = 0;
    
    // Fail数量
    public int FailNumber { get; set; } = 0;
    
    // 允许超过工单数量
    public bool AllowOverflow { get; set; } = false;
    
    [JsonConverter(typeof(CustomDateTimeConverter))]
    public DateTime CreateTime { get; set; }
    
    /// <summary>
    /// 导出时间
    /// </summary>
    [JsonConverter(typeof(CustomDateTimeConverter))]
    [SugarColumn(IsNullable = true)]
    public DateTime? ExportTime { get; set; }
    
    [SugarColumn(IsNullable = true)] public bool IsSynch { get; set; } = false;
    
    /// <summary>
    /// 导出位置
    /// </summary>
    [SugarColumn(IsNullable = true)]
    public string? ExportPath { get; set; }
    
    private bool _isSelected;
    [SugarColumn(IsIgnore = true)]
    public bool IsSelected
    {
        get => _isSelected;
        set
        {
            if (_isSelected != value)
            {
                _isSelected = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected)));
            }
        }
    }
}